# 字典是无序的 没有索引
#1. 定义字典 {key:value,...} 键值对
# dict_01 = {
#     "name":"damu",
#     "age":18,
#     0:"xxx"
# }
#2. 通过key访问value
# print(dict_01[0])
# print(dict_01["name"])

#3. in , not in , len()
# in: 判断key是否存在于对应的字典中
# print("name2" in dict_01)

#4. 遍历字典
# 遍历key
# for key in dict_01:
#     print(key)

# 遍历key , value
# for key in dict_01:
#     print(key,dict_01[key])

# 遍历嵌套的字典
# dict_02 = {
#     "name":"damu",
#     "age":18,
#     "wife":{
#         "name":"zdy",
#         "age":18
#     }
# }
# for key in dict_02:
#     value = dict_02[key]
#     if type(value) == dict:
#         for key2 in value:
#             print(key2, value[key2])

# 5. 常用的增删改查操作
#增 删 改
dict_03 = {"age":18,"wife":"zdy"}
# dict_03["name"] = "damu"
# del dict_03["name"]
# dict_03["name"] = "zdy"

# dict_03.clear()
# print(dict_03)

dict_04 = dict_03.copy()
print(dict_04)
#查 (遍历,通过key去取value)
print(dict_04["age"])
print(dict_04.get("age"))

print(dict_04.items())
print(dict_04.keys())
print(dict_04.values())

#6. 字典的常用方法

